package com.zzyl.nursing.controller.member;

import java.util.List;

import com.zzyl.nursing.dto.DeviceDataQueryDto;
import com.zzyl.nursing.dto.ElderDto;
import com.zzyl.nursing.dto.UserLoginRequestDto;
import com.zzyl.nursing.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.nursing.service.IFamilyMemberService;

/**
 * 老人家属Controller
 *
 * @author syl
 * @date 2025-05-30  member/user/login
 */
@RestController
@RequestMapping("/member/user")
@Api(tags = "老人家属的接口")
public class FamilyMemberController extends BaseController
{
    @Autowired
    private IFamilyMemberService familyMemberService;

    @DeleteMapping("/deleteById")
    public AjaxResult deleteById(Long id){
        familyMemberService.deleteById(id);
        return success();
    }

    @PostMapping("/login")
    @ApiOperation("老人家属的登录")
    public AjaxResult login(@RequestBody UserLoginRequestDto dto){
        LoginVo loginVo =  familyMemberService.login(dto);
        return success(loginVo);
    }

    @PostMapping("/add")
    @ApiOperation("绑定家人")
    public AjaxResult bind(@RequestBody ElderDto elderDto){
        familyMemberService.bind(elderDto);
        return success();
    }


    @GetMapping("/list-by-page")
    @ApiOperation("分页查询")
    public AjaxResult listByPage(){
        startPage();
        List<ElderVo> elderVos = familyMemberService.listByPage();
        return success(elderVos);
    }


    @GetMapping("/my")
    @ApiOperation("家人列表查询")
    public AjaxResult elderlist(){
        List<FamilyElderRelationVo> list = familyMemberService.elderlist();
        return success(list);
    }

    @GetMapping("/queryServiceProperties/{iotId}")
    @ApiOperation("查询健康数据")
    public AjaxResult queryServiceProperties(@PathVariable("iotId") String iotId){
        List<DeviceDataVo> list = familyMemberService.queryServiceProperties(iotId);
        return success(list);
    }

    @GetMapping("/queryDeviceDataListByDay")
    @ApiOperation("按天统计查询指标数据")
    public AjaxResult queryDeviceDataListByDay(DeviceDataQueryDto queryDTo){
        List<DeviceDataListVo> list = familyMemberService.queryDeviceDataListByDay(queryDTo);
        return success(list);
    }

    @GetMapping("/queryDeviceDataListByWeek")
    @ApiOperation("按周统计查询指标数据")
    public AjaxResult queryDeviceDataListByWeek(DeviceDataQueryDto queryDTo){
        List<DeviceDataListVo> list = familyMemberService.queryDeviceDataListByWeek(queryDTo);
        return success(list);
    }

}
